﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Text.Json;
using System.Text.Json.Serialization;


namespace SerializeBasic
{
    public class WeatherForecast
    {
        public DateTimeOffset Date { get; set; }
        public int TemperatureCelsius { get; set; }
        public string Summary { get; set; }
    }

    public class User
    {
        public string name { get; set; }
        public string addr { get; set; }
        public int age { get; set; }

    }
    public class Program
    {
        public static void Main()
        {
            var weatherForecast = new WeatherForecast
            {
                Date = DateTime.Parse("2019-08-01"),
                TemperatureCelsius = 25,
                Summary = "Hot"
            };

            string jsonString = JsonSerializer.Serialize(weatherForecast);

            Console.WriteLine(jsonString);




            String jsonStr = "{\"name\":\"yejing\",\"addr\":\"广州\",\"age\":34}";

            User user = JsonSerializer.Deserialize<User>(jsonStr);
            Console.WriteLine(user.name);


            

            Console.ReadLine();
        }
    }
}
